/**
 * Copyright (C) 2018-2021
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package co.yixiang.modules.product.service.impl;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import co.yixiang.api.BusinessException;
import co.yixiang.api.YshopException;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.enums.ProductTypeEnum;
import co.yixiang.exception.BadRequestException;
import co.yixiang.modules.product.domain.YxStoreProductExtend;
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
import co.yixiang.modules.product.service.YxStoreProductAttrService;
import co.yixiang.modules.product.service.YxStoreProductExtendService;
import co.yixiang.modules.product.service.dto.AttrValueDto;
import co.yixiang.modules.product.service.dto.FromatDetailDto;
import co.yixiang.modules.product.service.dto.ProductExtendDto;
import co.yixiang.modules.product.service.dto.ProductFormatDto;
import co.yixiang.modules.product.service.mapper.StoreProductExtendMapper;
import co.yixiang.modules.product.service.mapper.StoreProductAttrValueMapper;
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


/**
* @author hupeng
* @date 2020-05-12
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class YxStoreProductExtendServiceImpl extends BaseServiceImpl<StoreProductExtendMapper, YxStoreProductExtend> implements YxStoreProductExtendService {

    @Autowired
    private IGenerator generator;


    @Autowired
    private StoreProductAttrValueMapper yxStoreProductAttrValueMapper;


    @Autowired
    private YxStoreProductAttrResultService storeProductAttrResultService;

    /**
     * 新增商品属性
     * @param attrs value
     * @param productId 商品id
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insertYxStoreProductExtend(String jsonStr)
    {

        System.out.print(jsonStr);
        ProductExtendDto productExtendDto =JSON.parseObject(jsonStr,ProductExtendDto.class);

        System.out.print(productExtendDto);
        YxStoreProductExtend yxobj=new YxStoreProductExtend();
        yxobj.setProductId(productExtendDto.getProductId());
        yxobj.setAreaId(productExtendDto.getAreaId());
        yxobj.setPrice(productExtendDto.getPrice());
        yxobj.setActiveName(productExtendDto.getActiveName());
        yxobj.setActiveInfo(productExtendDto.getActiveInfo());
        yxobj.setMan(productExtendDto.getMan());
        yxobj.setZeng(productExtendDto.getZeng());
        yxobj.setTj(productExtendDto.getTj());
        this.save(yxobj);
    }



}
